package com.felix.thread;

/**
 * synchrronized
 *
 * @author xuejinhua
 * @date 2019/1/16 9:47
 */
public class Child extends Father {
    String name;

    public static void main(String[] args) {
        Child child = new Child();
        child.doSomething();
    }

    @Override
    public synchronized  void doSomething(){
        System.out.println("child.doSomething()");
        doAnotherThing(); // 调用自己类中其他的synchronized方法
    }
    public synchronized  void doAnotherThing(){
        super.doSomething(); // 调用父类的synchronized方法
        System.out.println("child.doAnotherThing()");
    }

}
class Father{

    public synchronized  void doSomething(){
        System.out.println("father.doSomething()");
    }
}